﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GeneralServices.Data
{
    /// <summary>
    /// 
    /// </summary>
    public class StoreApplicationDbContext
    {
        #region Attributs
        /// <summary>
        /// 
        /// </summary>
        private Dictionary<string, object> keyValue;

        /// <summary>
        /// 
        /// </summary>
        private static StoreApplicationDbContext _instance = null;
        #endregion

        #region Constructeur
        /// <summary>
        /// 
        /// </summary>
        private StoreApplicationDbContext()
        {
            keyValue = new Dictionary<string, object>(); 
        }           
        #endregion

        #region Méthodes
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void Register<T>(String key , T value)
        {
            if (_instance == null)
                _instance = new StoreApplicationDbContext();

            if (!_instance.keyValue.Keys.Contains(key))
                _instance.keyValue.Add(key, value);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static object Get(String key)
        {
            if (_instance.keyValue.Keys.Contains(key))
                return _instance.keyValue[key];
            else
                return null;
        }
        #endregion
        
    }
}
